require("module-alias/register")
require("@/zy-common/config/socket.js")
const koa = require('koa')
const router = require("./router")
const bodyParser = require('koa-bodyparser');
// const multer = require('koa-multer');
const {registerRoute} = require("./zy-common/utils")
const {APP_PORT} = require("@common/config")
const cors = require("@koa/cors")
const error = require('koa-json-error')
const handleError = require("@/zy-common/middleware/handleError.middleware")
// const inintSocket = require("@/zy-common/config/socket");

const app = new koa()


//inintSocket(app) //初始化socket.io
app.use(cors()) //解决跨域
app.use(bodyParser());
registerRoute(app)(router)
require("@common/config")
// app.use(error())
app.on('error',handleError)


app.listen(APP_PORT,() => {
  console.log(`${APP_PORT}服务器启动`);
})